const classNames = require('classnames')
const _ = require('../utils')

const component = {
  data: {
    value: false,
  },

  properties: {
    checked: {
      type: Boolean,
      value: false,
    },
    mode: {
      type: String,
      value: 'radio',
    },
  },

  behaviors: ['wx://form-field'],

  computed: {
    classes(data) {
      const { classPrefix, mode, checked } = data
      const classMode = `${classPrefix}-${mode}`
      const classes = classNames(classPrefix, classMode, {
        [`${classPrefix}-checked`]: checked,
      })

      return classes
    },
  },

  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    // created: function () {},
    // attached: function () { },
    // moved: function () { },
    // detached: function () { },
  },

  methods: {},
}

_.create('checkable', component)
